package io.geekidea.springbootplus.system.service.impl;

import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.system.entity.SysFavourite;
import io.geekidea.springbootplus.system.mapper.SysFavouriteMapper;
import io.geekidea.springbootplus.system.service.SysFavouriteService;
import io.geekidea.springbootplus.system.vo.SysFavouriteVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
public class SysFavouriteServiceImpl extends BaseServiceImpl<SysFavouriteMapper, SysFavourite> implements SysFavouriteService {


    @Resource
    private SysFavouriteMapper favouriteMapper;

    @Override
    public boolean addToFavorites(SysFavourite favourite) throws Exception {
        return favouriteMapper.insertFavourite(favourite)>0;
    }

    @Override
    public boolean deleteFavorites(Integer id) throws Exception {

        return favouriteMapper.deleteFavourite(id)>0;
    }

    @Override
    public boolean deleteAllFavorites(List<Integer> ids) throws Exception {
        return favouriteMapper.deleteAllFavourite(ids)>0;
    }

    @Override
    public List<SysFavouriteVo> findFavouriteById(Integer id) throws Exception {
        return favouriteMapper.selectFavouriteById(id);
    }
}
